cody - HTMLify profile

cody
4270 Files
632542 Views
Latest files of /cody/solygambas/html-css-javascript-projects/025-sticky navigation
@import url("https://fonts.googleapis.com/css?family=Open+Sans&display=swap");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Sticky Navigation</title>
</head>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Sticky Navigation</title>
</head>
const nav = document.querySelector(".nav");
const fixNav = () => {
if (window.scrollY > nav.offsetHeight + 150) nav.classList.add("active");
else nav.classList.remove("active");
};
window.addEventListener("scroll", fixNav);
const fixNav = () => {
if (window.scrollY > nav.offsetHeight + 150) nav.classList.add("active");
else nav.classList.remove("active");
};
window.addEventListener("scroll", fixNav);